home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 1.iso / toolbox / src / demos / OpenGL / space / main.c < prev    next >
C/C++ Source or Header  |  1996-11-11  |  19KB  |  655 lines

  1. /*
  2.  * Copyright (C) 1992, 1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. #include "space.h"
  18.  
  19. static uint16 cursor[16] = {
  20.           0x0100, 0x0100, 0x0100, 0x0100,
  21.           0x0100, 0x0100, 0x0100, 0xFFFE,
  22.           0x0100, 0x0100, 0x0100, 0x0100,
  23.           0x0100, 0x0100, 0x0100, 0x0000
  24. } ;
  25.  
  26. static flot32 blurray[3][3] = {
  27.        0.05, 0.10, 0.05,
  28.        0.10, 0.80, 0.10,
  29.        0.05, 0.10, 0.05,
  30. } ;
  31.  
  32. char       datapath[256] ;
  33. V4         raww[NUM_CLIP_PLANES] ;
  34. t_boss     flaggs ;
  35. t_galaga   ggaa[STARSQ][STARSQ] ;
  36. extern t_stopwatch Counter ;
  37. long       control_height;
  38.  
  39. static char *space_assist[] = {
  40.          " COMMAND LINE ARGS",
  41.          "   -h       : help",
  42.          "   -f path  : set data directory path",
  43.          "",
  44.          0
  45. } ;
  46.  
  47. static char *space_help[] = {
  48.          " MOUSE CONTROLS",
  49.          "    left   : accelerates",
  50.          "    middle : brakes",
  51.          "    right  : pan/rotate toggle",
  52.          "",
  53.          "    left+right        : face nearest moon",
  54.          "    middle+right      : face nearest planet",
  55.          "    left+middle       : face nearest star",
  56.          "    left+middle+right : face companion star",
  57.          "",
  58.          " KEY CONTROLS",
  59.          "    Esc   : quit",
  60.          "    Shift : defeat mouse controls (for menu)",
  61.          "    Ctrl  : disconnect view vector from velocity vector",
  62.          "    a : autopilot",
  63.          "    b : single buffer mode (left mouse is trigger)",
  64.          "    h : on screen help toggle",
  65.          "    i : moons/orbits toggle",
  66.          "    l : reshade polyplanet every frame",
  67.          "    n : star name toggle",
  68.          "    o : planets/orbits toggle",
  69.          "    q : control panel toggle",
  70.          "    r : decelerates time by 10",
  71.          "    s : stellar system statistics",
  72.          "    t : accelerates time by 10",
  73.          "    u : user entry mode (use with system statistics)",
  74.          "    v : reverse velocity",
  75.          "    x : text display toggle",
  76.          "    y : time reset",
  77.          "    z : display constellation boundaries",
  78.          "    - : time direction toggle",
  79.          "    up   arrow : increase tesselation level (max: 5)",
  80.          "    down arrow : decrease tesselation level (min: 0)",
  81.          "    PrintScrn  : snap rgb image and quit",
  82.          "",
  83.          " TEXT COLOR CODES",
  84.          "    red   : in interplanetary space",
  85.          "    blue  : in interstellar space",
  86.          "    yellow: in intergalactic space",
  87.          "    green : currently being eclipsed",
  88.          "",
  89.          " TOURIST SPOTS",
  90.          "    Sol   :    0",
  91.          "    Sirius:  714",
  92.          "    Mizar : 1421",
  93.          0
  94. } ;
  95.  
  96. static char *opening_credit[] = {
  97.          "SGI Space Simulator Version 2.00",
  98.          "",
  99.          "",
  100.          "A simulation of the Solar System and the Milky Way galaxy",
  101.          "with certain artistic liberties.",
  102.          0
  103. } ;
  104.  
  105. static char *geosphere_credit[] = {
  106.          "Satellite Earth color data provided by",
  107.          "TOM VAN SANT and the GEOSPHERE PROJECT",
  108.          "With assistance from NOAA, NASA, EYES ON EARTH",
  109.          "Technical Direction Lloyd van Warren, Leo Blume, Jim Knighton",
  110.          "Source data derived from NOAA/TIROS-N Series Satellites",
  111.          "All rights reserved by Tom Van Sant, Inc.",
  112.          "146 Entrada Drive, Santa Monica, CA 90402",
  113.          "310-459-4342",
  114.          0
  115. } ;
  116.  
  117. static char *sub_geosphere_credit[] = {
  118.          "SATELLITE EARTH COLOR DATA",
  119.          "Tom Van Sant/The Geosphere Project",
  120.          "L.V. Warren, L. Blume, J. Knighton",
  121.          "Santa Monica, CA  310-459-4342",
  122.          0
  123. } ;
  124.  
  125. int GeosphereData = 0;
  126.  
  127. static Bool WaitForNotify(Display *d, XEvent *e, char *arg)
  128.    { return (e->type == MapNotify) && (e->xmap.window == (Window)arg); }
  129.  
  130. /**********************************************************************/
  131. /*  MAIN ()                                                           */
  132. /**********************************************************************/
  133. main(sint32 argc,char *argv[])
  134.  
  135. {  char   *token ;
  136.    sint32 i ;
  137.  
  138.    Counter.flags = PRBIT_FLAG | MRBIT_FLAG | FLSCR_FLAG;
  139.  
  140.    while (--argc > 0 && **++argv == '-')
  141.        for (token = argv[0]+1; *token; token++)
  142.           switch (*token) {
  143.             case 'd': Counter.flags &= ~FLSCR_FLAG ;
  144.                       break ;
  145.             case 'f': Counter.flags |= DPATH_FLAG ;
  146.                       argc-- ;
  147.                       strcpy(datapath,*++argv) ;
  148.                       strcat(datapath,"/") ;
  149.                       break ;
  150.             case 'h': for (i=0; space_assist[i] != NULL; i++)
  151.                         fprintf(stdout,"\t%s\n", space_assist[i]);
  152.                       for (i=0; space_help[i] != NULL; i++)
  153.                         fprintf(stdout,"\t%s\n", space_help[i]);
  154.                       exit(0) ;
  155.                       break ;
  156.             case 's': Counter.flags |= SPACB_FLAG ;
  157.                       break ;
  158.             default : printf("Invalid Option: %d\n",*token) ;
  159.                       exit(0) ;
  160.                       break ;
  161.             }
  162.  
  163.    spIdentifyMachine();
  164.    spQuantifyMachine();
  165.  
  166.    if (!spOpenWindow())
  167.      exit(-1);
  168.  
  169.    if (!spInitFont("-adobe-times-bold-r-normal--0-150-100-100-p-100-iso8859-1")) {
  170.      char cha[512];
  171.  
  172.      printf("Cannot initialize font, please enter name of new font:");
  173.      scanf("%s",cha);
  174.  
  175.      if (!spInitFont(cha)) {
  176.        printf("Cannot find alternate font");
  177.        exit(-1);
  178.        }
  179.      }
  180.  
  181.    initialize_graphics() ;
  182.    spInitCursor();
  183.    spInitBell();
  184.    spInitKeyboard();
  185.    initialize_time() ;
  186.    initialize_shmem(&flaggs) ;
  187.  
  188.    key_press(&flaggs,SP_IO_q);
  189.  
  190.    fly() ;
  191. }
  192.  
  193. /**********************************************************************/
  194. /*  initialize_graphics()                                             */
  195. /**********************************************************************/
  196. static void initialize_graphics(void)
  197.  
  198. {  flot32 tevps[8],texps[8],att[4] ;
  199.    sint32 i,j,k,m ;
  200.    int    arr[8] ;
  201.    uint32 txt[32*32],qwe[256][256] ;
  202.    uint16 stt[128*128] ;
  203.    char   *p ;
  204.    FILE   *fd ;
  205.  
  206.    set_window_view(300.0) ;
  207.  
  208.    glDepthFunc(GL_LEQUAL);
  209.    glClearDepth(1.0) ;
  210.    glShadeModel(GL_FLAT);
  211.    glCullFace(GL_BACK) ;
  212.    glEnable(GL_CULL_FACE) ;
  213.  
  214.    glBlendFunc(GL_SRC_ALPHA, GL_ONE);
  215.  
  216.    glClearColor(0.0,0.0,0.0,0.0) ;
  217.    glClear(GL_COLOR_BUFFER_BIT) ;
  218.  
  219.    print_opening_credit() ;
  220.    spSwapBuffers();
  221.  
  222.    spTevDef();
  223.  
  224.    if (Counter.alpha & HW_AAPNT)
  225.      glEnable(GL_POINT_SMOOTH);
  226.  
  227.    if (Counter.alpha & HW_AALIN)
  228.      glEnable(GL_LINE_SMOOTH);
  229.  
  230.    spInitLight();
  231.  
  232.    Counter.sky_clear_color[0] = 0.0 ;
  233.    Counter.sky_clear_color[1] = 0.0 ;
  234.    Counter.sky_clear_color[2] = 0.0 ;
  235.    Counter.sky_clear_color[3] = 0.0 ;
  236.  
  237.    for (p=(char *)txt,i=0; i<32; i++)
  238.      for (j=0; j<32; j++)  {
  239.        if (((i&8) + (j&8)) & 8)
  240.          *p++ = 0x80 ;
  241.        else *p++ = 0xff ;
  242.        }
  243.    flaggs.stat.texdf = spTexDef(1,32,32,txt,1);
  244.  
  245.    flaggs.stat.cliprad = 150.0 ;
  246.    flaggs.stat.bodyobj[0] = object_space_station(12) ;
  247.    flaggs.stat.bodyobj[1] = object_space_station(8) ;
  248.    flaggs.stat.bodyobj[2] = object_space_station(4) ;
  249.    Counter.shadowsqobj = object_shadow_squares() ;
  250.  
  251. #if 0
  252.    Yread();
  253. #endif
  254.  
  255.    if (fd = fopen(datatrail("corona.ring"),"r")) {
  256.      fread(stt,2,128*128,fd) ;
  257.      fclose(fd) ;
  258.      Counter.corona = spTexDef(2,128,128,stt,0);
  259.      }
  260.    else  {
  261.      printf("USER ERROR: Texture file not found: %s\n",datatrail("corona.ring")) ;
  262.      exit(0) ;
  263.      }
  264.  
  265.    if (fd = fopen(datatrail("galaxy.texture"),"r")) {
  266.      fread(qwe,4,256*256,fd) ;
  267.      fclose(fd) ;
  268.      Counter.galaxy = spTexDef(4,256,256,qwe,0);
  269.      }
  270.    else  {
  271.      printf("USER ERROR: Texture file not found: %s\n",datatrail("galaxy.texture")) ;
  272.      exit(0) ;
  273.      }
  274.  
  275.    blur_galaxy(qwe) ;
  276. }
  277.  
  278. /********************************************************************** 
  279. *  fly()  -  
  280. **********************************************************************/
  281. static void fly(void)
  282.  
  283. {  register flot32 timer,timer_old;
  284.    register sint32 i,clocker ;
  285.    register t_body *tb;
  286.  
  287.    timer_old   = Counter.timer_old ;
  288.    timer       = Counter.timer ;
  289.    Counter.fps = 20.0 ;
  290.    clocker     = 20 ;
  291.  
  292.    while(1) {
  293.         read_time() ;
  294.  
  295.         scan_galactic_system(&flaggs) ;
  296.  
  297.         spReadEvents(&flaggs) ;
  298.  
  299.         evaluate_mouse(&flaggs) ;
  300.  
  301.         glClearColor(0.0,0.0,0.0,0.0) ;
  302.         glClearDepth(1.0) ;
  303.  
  304.         switch (Counter.status)  {
  305.           case STELL_STAT:
  306.             if ((flaggs.plan_current < 0) || (Counter.flags & PRBIT_FLAG)) {
  307.               glClear(GL_COLOR_BUFFER_BIT) ;
  308.               }
  309.             else {
  310.               glClearColor(Counter.sky_clear_color[0], Counter.sky_clear_color[1],
  311.                            Counter.sky_clear_color[2], Counter.sky_clear_color[3]);
  312.               glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) ;
  313.               }
  314.             break;
  315.  
  316.           case GALAC_STAT:
  317.             glClear(GL_COLOR_BUFFER_BIT) ;
  318.             break;
  319.  
  320.           case COSMC_STAT:
  321.             if (Counter.flags & TEXTR_FLAG)
  322.               glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) ;
  323.             else if (Counter.flags & SLOWZ_FLAG)
  324.               glClear(GL_COLOR_BUFFER_BIT) ;
  325.             else 
  326.               glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) ;
  327.             break;
  328.           }
  329.  
  330.     Counter.sky_clear_color[0] = 0.0 ;
  331.     Counter.sky_clear_color[1] = 0.0 ;
  332.     Counter.sky_clear_color[2] = 0.0 ;
  333.     Counter.sky_clear_color[3] = 0.0 ;
  334.  
  335.         if (Counter.flags & ACCUM_FLAG) {
  336.           accumulation(&flaggs);
  337.           Counter.flags &= ~ACCUM_FLAG;
  338.           }
  339.         else actually_do_graphics(&flaggs);
  340.  
  341.         if (Counter.flags & HELPP_FLAG || !(Counter.flags & NOTXT_FLAG) || (Counter.flags & GEOSP_FLAG))
  342.           print_screen_text(Counter.fps) ;
  343.  
  344.         if (Counter.flags & PRINT_FLAG)  {
  345.           savescreen(Counter.winsizex,Counter.winsizey);
  346.           exit(0) ;
  347.           }
  348.  
  349.         spSwapBuffers();
  350.  
  351.         if (--clocker <= 0)  {
  352.           timer_old = timer ;
  353.           timer     = Counter.timer ;
  354.  
  355.           Counter.fps = ((Counter.fps < 1.0) ? 1.0 : (sint32)Counter.fps) / (timer - timer_old) ;
  356.           clocker = Counter.fps ;
  357.           }
  358.     }
  359. }
  360.  
  361. /********************************************************************** 
  362. *  print_screen_text()  -  
  363. **********************************************************************/
  364. static void print_screen_text(register flot32 fps)
  365.  
  366. {  flot32 vel ;
  367.    sint32 i ;
  368.    schar8 sped[32],fpsc[32];
  369.    uchar8 cl[3] ;
  370.  
  371.    glMatrixMode(GL_PROJECTION);
  372.    glLoadIdentity();
  373.    glOrtho(0.0,1.0,0.0,1.0,-1.0,1.0) ;
  374.    glMatrixMode(GL_MODELVIEW);
  375.    glLoadIdentity();
  376.  
  377.    if (!(Counter.flags & NOTXT_FLAG))  {
  378.      cl[0] = (Counter.infoco >>  0) & 0xff;
  379.      cl[1] = (Counter.infoco >>  8) & 0xff;
  380.      cl[2] = (Counter.infoco >> 16) & 0xff;
  381.      glColor3ubv(cl);
  382.  
  383.      spDrawString(0.01,0.97,0.0,Counter.date) ;
  384.  
  385.      vel = Counter.S / LIGHTSPEED ;
  386.  
  387.      if (Counter.status != STELL_STAT)
  388.        vel *= PRTOKM ;
  389.  
  390.      if (Counter.flags & AUTOP_FLAG)
  391.        sprintf(sped,"Auto Pilot\n") ;
  392.      else  {
  393.        if (vel >= 1.0) {
  394.          vel = 1.0 + flog10(vel) ;
  395.          sprintf(sped,"Speed: %.2fw\n",vel) ;
  396.          }
  397.        else if (vel >= 0.01)
  398.          sprintf(sped,"Speed: %.3fc\n",vel) ;
  399.        else sprintf(sped,"Speed: %.2fkm/s\n",vel*LIGHTSPEED) ;
  400.        }
  401.  
  402.      spDrawString(0.01,0.94,0.0,sped) ;
  403.  
  404.      sprintf(fpsc,"F/sec: %.2f\n",fps) ;
  405.      spDrawString(0.01,0.91,0.0,fpsc) ;
  406.  
  407.      if (Counter.flags & USERM_FLAG) {
  408.        sprintf(fpsc,"User Entry Mode\n") ;
  409.        spDrawString(0.01,0.88,0.0,fpsc) ;
  410.        }
  411.      }
  412.  
  413.    if (Counter.flags & HELPP_FLAG) {
  414.      glColor4f(0.5,0.75,0.5,1.0);
  415.  
  416.      for (vel=0.95,i=0; space_help[i] != NULL; vel-=0.02,i++) 
  417.        spDrawString(0.25,vel,0.0,space_help[i]);
  418.      }
  419.  
  420.    if (Counter.flags & GEOSP_FLAG)  {
  421.      glColor4ubv((unsigned char *)&Counter.infoco) ;
  422.      for (vel=0.97,i=0; sub_geosphere_credit[i] != NULL; vel-=0.025,i++)
  423.        spDrawString(0.70,vel,0.0,sub_geosphere_credit[i]);
  424.      }
  425. }
  426.  
  427. /********************************************************************** 
  428. *  blur_galaxy()  -  
  429. **********************************************************************/
  430. static void blur_galaxy(uint32 qwe[256][256])
  431.  
  432. {  register flot32   *a,sum,ar[STARSQ][STARSQ],br[STARSQ][STARSQ],biggest ;
  433.    register sint32   i,j,k,m,delta ;
  434.    register uint32   psum,col ;
  435.    register t_galaga *gg ;
  436.  
  437.    delta = 256/STARSQ ;
  438.  
  439.    for (i=0; i<256; i+=delta)
  440.      for (j=0; j<256; j+=delta)  {
  441.        for (psum=0,k=i; k<i+delta; k++)
  442.          for (m=j; m<j+delta; m++)  {
  443.             col = qwe[k][m] ;
  444.             psum += (col & 0xff) + ((col>> 8) & 0xff) + ((col>>16) & 0xff) ;
  445.             }
  446.        ar[i/delta][j/delta] = psum ;
  447.        }
  448.  
  449.    for (i=0; i<STARSQ; i++)  {
  450.      br[i       ][0       ] = 0.0 ;
  451.      br[i       ][STARSQ-1] = 0.0 ;
  452.      br[0       ][i       ] = 0.0 ;
  453.      br[STARSQ-1][i       ] = 0.0 ;
  454.      }
  455.  
  456.    for (biggest=0.0,i=1; i<STARSQ-1; i++)
  457.      for (j=1; j<STARSQ-1; j++)  {
  458.        for (sum=k=0; k<3; k++)
  459.          for (m=0; m<3; m++) 
  460.            sum += blurray[k][m] * ar[i+k-1][j+m-1] ;
  461.           
  462.        br[i][j] = sum ;
  463.  
  464.        if (sum > biggest)
  465.          biggest = sum ;
  466.        }
  467.  
  468.    biggest = 1024.0 * fsqrt(1.0/biggest) ;
  469.  
  470.    for (gg=ggaa[0],i=0; i<STARSQ; i++)
  471.      for (j=0; j<STARSQ; gg++,j++)  {
  472.        gg->count = (flot32) biggest * fsqrt(br[i][j]) ;
  473.        gg->stars = NULL ;
  474.        }
  475. }
  476.  
  477. /********************************************************************** 
  478. *  make_galaxy_object()  -  
  479. **********************************************************************/
  480. sint32 make_galaxy_object(sint32 flag)
  481.  
  482. {  register sint32 obj,i,j,col,step ;
  483.    register T2     t[2] ;
  484.    register P3     p[2] ;
  485.    register flot32 delt,edge,q ;
  486.  
  487.    obj = glGenLists(1);
  488.    glNewList(obj,GL_COMPILE) ;
  489.  
  490.    if (flag)  {
  491.      delt = 1.0/16.0 ;
  492.      edge = GALAXY_EDGE/16.0 ;
  493.      step = STARSQ/16 ;
  494.      i = STARSQ ;
  495.      }
  496.    else  {
  497.      delt = 1.0/32.0 ;
  498.      edge = GALAXY_EDGE/32.0 ;
  499.      step = STARSQ/32 ;
  500.      i = STARSQ - step - 1 ;
  501.      }
  502.   
  503.    t[0].t = 0.0 ;
  504.    t[1].t = delt ;
  505.    p[0].z = -0.5*GALAXY_EDGE ;
  506.    p[1].z = p[0].z + edge ;
  507.  
  508.    for (; i>=0; i-=step)  {
  509.      glBegin(GL_TRIANGLE_STRIP) ;
  510.   
  511.      t[0].s = 0.0 ;
  512.      t[1].s = 0.0 ;
  513.      p[0].x = -0.5*GALAXY_EDGE ;
  514.      p[1].x = -0.5*GALAXY_EDGE ;
  515.  
  516.      j = (flag ? STARSQ : STARSQ-step-1) ;
  517.      for (; j>=0; j-=step)  {
  518.        if (flag)
  519.          glTexCoord2fv(&t[1].s) ;
  520.        else  {
  521.          col = ggaa[i][j].count*255.0/Counter.stars_per_square ;
  522.          if (col > 255.0) col = 255.0 ;
  523.          glColor4ub(col,col,col,255);
  524.          }
  525.  
  526.        p[1].y = edge*exp(-40.0*((t[1].s-0.5)*(t[1].s-0.5) + (t[1].t-0.5)*(t[1].t-0.5))) ;
  527.        glVertex3fv(&p[1].x) ;
  528.  
  529.        if (flag)
  530.          glTexCoord2fv(&t[0].s) ;
  531.        else  {
  532.          col = ggaa[i+step][j].count*255.0/Counter.stars_per_square ;
  533.          if (col > 255.0) col = 255.0 ;
  534.          glColor4ub(col,col,col,255);
  535.          }
  536.  
  537.        p[0].y = edge*exp(-40.0*((t[0].s-0.5)*(t[0].s-0.5) + (t[0].t-0.5)*(t[0].t-0.5))) ;
  538.        glVertex3fv(&p[0].x) ;
  539.   
  540.        t[0].s += delt ;
  541.        t[1].s += delt ;
  542.        p[0].x += edge ;
  543.        p[1].x += edge ;
  544.        }
  545.   
  546.      glEnd() ;
  547.   
  548.      t[0].t += delt ;
  549.      t[1].t += delt ;
  550.      p[0].z += edge ;
  551.      p[1].z += edge ;
  552.      }
  553.  
  554.    glEndList();
  555.    return(obj) ;
  556. }
  557.  
  558. /**********************************************************************/
  559. /*  set_window_view()                                                 */
  560. /**********************************************************************/
  561. void set_window_view(flot32 vian)
  562.  
  563. {  register flot32 s,c,h_view_angle,v_view_angle ;
  564.  
  565.    spGetWindowGeometry();
  566.  
  567.    control_height = (192*Counter.winsizey)/1024;
  568.    Counter.viewangle = vian ;
  569.  
  570.    if (Counter.flags & PANEL_FLAG)
  571.      Counter.aspcratio = (flot32)Counter.winsizex/(flot32)(Counter.winsizey - control_height) ;
  572.    else Counter.aspcratio = (flot32)Counter.winsizex/(flot32)Counter.winsizey ;
  573.  
  574.    Counter.fov = 1.0/ftan(Counter.viewangle*M_PI/3600.0);
  575.  
  576.    v_view_angle = Counter.viewangle * M_PI / 1800.0  ;
  577.    h_view_angle = v_view_angle * Counter.aspcratio ;
  578.  
  579.    c = fcos(0.5*h_view_angle) ;
  580.    s = fsin(0.5*h_view_angle) ;
  581.  
  582.    raww[0].x =  c ;
  583.    raww[0].y =  0.0 ;
  584.    raww[0].z = -s ;
  585.    raww[0].w =  0.0 ;
  586.  
  587.    raww[2].x = -c ;
  588.    raww[2].y =  0.0 ;
  589.    raww[2].z = -s ;
  590.    raww[2].w =  0.0 ;
  591.  
  592.    c = fcos(0.5*v_view_angle) ;
  593.    s = fsin(0.5*v_view_angle) ;
  594.  
  595.    raww[1].x =  0.0 ;
  596.    raww[1].y =  c ;
  597.    raww[1].z = -s ;
  598.    raww[1].w =  0.0 ;
  599.  
  600.    raww[3].x =  0.0 ;
  601.    raww[3].y = -c ;
  602.    raww[3].z = -s ;
  603.    raww[3].w =  0.0 ;
  604.  
  605.    raww[4].x =  0.0 ;
  606.    raww[4].y =  0.0 ; 
  607.    raww[4].z = -1.0 ;
  608.    raww[4].w =  0.0 ;
  609. }
  610.  
  611. /**********************************************************************/
  612. /*  print_opening_credit()                                            */
  613. /**********************************************************************/
  614. static void print_opening_credit(void)
  615.  
  616. {  flot32 vel ;
  617.    sint32 i ;
  618.  
  619.    glMatrixMode(GL_PROJECTION);
  620.    glLoadIdentity();
  621.    glOrtho(0.0,1.0,0.0,1.0,-1.0,1.0) ;
  622.    glMatrixMode(GL_MODELVIEW);
  623.    glLoadIdentity();
  624.  
  625.    glColor4f(1.0,1.0,1.0,1.0);
  626.  
  627.    for (vel=0.80,i=0; opening_credit[i] != NULL; vel-=0.02,i++) 
  628.      spDrawString(0.30,vel,0.0,opening_credit[i]);
  629.  
  630.    if (GeosphereData)
  631.      for (vel=0.40,i=0; geosphere_credit[i] != NULL; vel-=0.02,i++) 
  632.        spDrawString(0.30,vel,0.0,geosphere_credit[i]);
  633. }
  634.  
  635. /**********************************************************************/
  636. /*  datatrail()  -                                                    */
  637. /**********************************************************************/
  638. char *datatrail(char *name) 
  639.  
  640. {  static char filename[256] ;
  641.  
  642.    if (Counter.flags & DPATH_FLAG) {  
  643.      strcpy(filename,datapath) ;
  644.      strcat(filename,name) ;
  645.      }
  646.    else  {
  647.      getcwd(filename, 256);
  648.      strcat(filename,"/data/") ;
  649.      strcat(filename,name) ;
  650.      }
  651.  
  652.    return(filename) ;
  653. }
  654.  
  655.